#ifndef FILEPATH_H
#define FILEPATH_H

#include <string>
#include <list>

class FilePath
{
public:
	enum Type
	{
		UNIX,
		WINDOWS
	};

	enum ResolveType
	{
		AUTORESOLVE,
		NORESOLVE
	};

	FilePath(ResolveType resolveType = AUTORESOLVE, Type type=WINDOWS);
	FilePath(const std::string& path, ResolveType resolveType = AUTORESOLVE, Type type=WINDOWS);
	FilePath(const FilePath& rhs);
	FilePath& operator=(const FilePath& rhs);
	~FilePath();

	void Clear();
	void Resolve();

	void SetPath(const std::string& path);
	std::string PathString() const;
	std::string FilenameString() const;
	const std::string& VolumeString() const;
	FilePath Parent() const;
	bool IsAbsolute() const { return volume.length() != 0; }
	bool HasPrefix(const FilePath& rhs) const;
	void Append(const FilePath& filepath, bool ignoreVolume = false);

	FilePath operator+(const FilePath& rhs) const;
	FilePath& operator+=(const FilePath& rhs);
	bool operator==(const FilePath& rhs) const;
	bool operator!=(const FilePath& rhs) const;


private:
	Type type;
	ResolveType resolve;
	char seperator;
	std::string volume;

	static const char* seperators;

	bool IsVolume(const std::string& dir);
	bool IsUnixVolume(const std::string& dir);
	bool IsWindowsVolume(const std::string& dir);
	bool IsSinglePoint(const std::string& dir) const;
	bool IsDoublePoint(const std::string& dir) const;


	void BuildList(const std::string& path);
	void FilterList();
	void FilterVolume(bool writeback);
	void SetSeperator(FilePath::Type pathtype);

	std::list<std::string> dirs;
};

#endif // FILEPATH_H